package com.wsjzzcbq.util;

import com.wsjzzcbq.constant.AppConsts;
import com.wsjzzcbq.ui.info.WindowInfo;
import java.awt.*;
import java.util.UUID;

/**
 * SysUtils
 *
 * @author wsjz
 * @date 2022/04/06
 */
public class SysUtils {

    public static String uuid() {
        return UUID.randomUUID().toString();
    }

    public static int location(int size, int widthOrHeight) {
        return (widthOrHeight - size)/2;
    }

    /**
     * 内层iframe偏移量
     * @param size
     * @return
     */
    public static int innerLocation(int size) {
        return (AppConsts.GLOBAL_SIZE - size) / 2;
    }

    public static int innerLocationX(int size) {
        Point point = WindowInfo.location();
        return point.x + innerLocation(size);
    }

    public static int innerLocationY(int size) {
        Point point = WindowInfo.location();
        return point.y + innerLocation(size);
    }

    /**
     * cpu核心数
     * @return
     */
    public static int processors() {
        System.out.println(Runtime.getRuntime().freeMemory() / 1024 / 1024);
        System.out.println(Runtime.getRuntime().maxMemory() / 1024 / 1024);
        System.out.println(Runtime.getRuntime().totalMemory() / 1024 / 1024);
        return Runtime.getRuntime().availableProcessors();
    }

}
